package com.lz.concurrent;

import org.junit.Test;

import java.util.concurrent.atomic.LongAdder;

/**
 * LonAdder方法使用{@link LongAdder} 多线程求和
 *
 * @author: li
 * @date: 2019/1/14
 */
public class LongAdderTest {
    @Test
    public void  test01(){
        LongAdder longAdder = new LongAdder();
        for(int i=0;i<100;i++){

        longAdder.increment();
        }
        System.out.println(longAdder.intValue());
        System.out.println(longAdder.sum());
        System.out.println(longAdder.sumThenReset());
        System.out.println(longAdder.sum());
    }
}
